﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using YasharEl.Infrastructure.PersistenceModel;
using YasharEl.Infrastructure.EntityModel;
using YasharEl.Infrastructure.EntityModel.Specifications;
using YasharEl.Infrastructure.Core.Personification;
using YasharEl.Infrastructure.TaskEngine.PersistenceModel.Repositories;
using YasharEl.Infrastructure.TaskEngine.PersistenceModel.Specifications;

namespace YasharEl.Infrastructure.TaskEngine.PersistenceModel.NHibernate.Repositories
{
    public class TaskParticipantsRepository : GenericRepository<ITaskParticipant, long>, ITaskParticipantsRepository
    {
        public TaskParticipantsRepository(IUnitOfWork unitOfWork, ISpecificationLocator specificationLocator)
            : base(unitOfWork, specificationLocator)
        {

        }

        public ITaskParticipant FindParticipantByIdentityNumber(long identityNumber)
        {
            return Specify<ITaskParticipantSpecification>()
                    .WithIdentityNumber(new IsraelIdentityNumber(identityNumber))
                    .ToResult()
                    .SingleOrDefault();
        }
    }
}
